<template>
  <div style=" width: 99%; margin: auto;">
    <el-row>
      <el-col :span="18">
        <h3>上年度整改情况表</h3>
      </el-col>
      <el-col :span="6" style="color: #1890ff;">
        <h4>上年度检查结果：{{ yearResult }}</h4>
      </el-col>
    </el-row>
    <h4>（未参加上年度年检或上年度年检结论为基本合格的填写）</h4>
    <!--    <h5 style="text-align: right; color: red;">上年度年检结果: </h5>-->
    <div style="width: 100%;font-size: 14px;"><h1 style="margin-top: 20px;margin-bottom: 20px; font-size: 14px;">
      造成未参检（或基本合格）原因</h1>
      <el-form :model="postForm" ref="postFormRef" :rules="postRules">
        <el-form-item prop="reason" :rules="postRules.reason">
          <el-input type="textarea" placeholder="请输入" :rows="6" v-model="postForm.reason" maxlength="2000"
                    show-word-limit />
        </el-form-item>
        <h1 style="margin-top: 20px;margin-bottom: 20px; font-size: 14px;">整改措施</h1>
        <el-form-item prop="measure" :rules="postRules.measure">
          <el-input type="textarea" placeholder="请输入" :rows="6" v-model="postForm.measure" maxlength="2000"
                    show-word-limit />
        </el-form-item>
        <h1 style="margin-top: 20px;margin-bottom: 20px; font-size: 14px;">整改效果</h1>
        <el-form-item prop="effect" :rules="postRules.effect">
          <el-input style="margin-bottom: 50px;" type="textarea" placeholder="请输入" :rows="6" v-model="postForm.effect" maxlength="2000"
                    show-word-limit />
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import { getTableInfoByPage, mfSaveDjParty, mfSaveRectification, mfResult } from '@/views/yearCheck/ykb/mf/mf'

export default {
  data() {
    return {
      yearResult: '',
      postForm: {
        creditCode: localStorage.getItem('creditCode'),//统一社会信用代码
        effect: '',//整改效果
        examineYear: localStorage.getItem('examineYear'),//审查年度
        id: '',//整改情况id
        measure: '',//整改措施
        organizationBaseId: '1',//组织id
        reason: ''//造成未参检
      },
      postRules: {
        // reason: [{ required: true, message: '请输入造成未参检', trigger: 'blur' }],
        // measure: [{ required: true, message: '请输入整改措施', trigger: 'blur' }],
        // effect: [{ required: true, message: '请输入整改效果', trigger: 'blur' }]
      }
    }
  },

  created() {

  },
  methods: {
    postInfo() {
      this.postForm.creditCode = localStorage.getItem('creditCode')
      this.postForm.examineYear = localStorage.getItem('examineYear')
      this.postForm.organizationBaseId = '1'
      this.$refs.postFormRef.validate(valid => {
        if (valid) {
          mfSaveRectification(this.postForm).then(response => {
            this.$message({
              message: '年度整改情况表保存成功！',
              type: 'success'
            })
            this.getInfo()
          })
        } else {
          this.$message({
            message: '请填写完整！',
            type: 'error'
          })
        }
      })

    },
    getInfo() {
      getTableInfoByPage(24).then(response => {
        this.postForm = JSON.parse(JSON.stringify(response.data).replace(/null/g, '""'))
      })

      mfResult({
        creditCode: localStorage.getItem('creditCode'),
        examineYear: localStorage.getItem('examineYear') - 1
      }).then(response => {
        console.log(response)

        if (response.approveStatus == null || response.approveStatus.approveStatus == '') {
          this.yearResult = '未年检'
        } else if (response.approveStatus == 1) {
          this.yearResult = '合格'
        } else if (response.approveStatus == 2) {
          this.yearResult = '基本合格'
        } else if (response.approveStatus == 3) {
          this.yearResult = '不合格'
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
.el-table {
  --el-table-row-hover-bg-color: rgba(39, 137, 238, 0.1);
  --el-table-border-color:#e0e5f0;
}
:deep(.el-card.is-always-shadow) {
  box-shadow: 0 1px 14px 0 rgba(209, 224, 239, 0.6)
}

/* 拉框选中 */
.el-select-dropdown__item {
  height: 24px;
  line-height: 24px;
  font-size: 12px;
}

/* 鼠标经过下拉框 */
.el-select-dropdown__item:hover {
  height: 24px;
  line-height: 24px;
  font-size: 12px;
}

.el-select-dropdown__item.selected {
  color: #2789EE;
}
.app-container {
  margin-top: 40px;
  margin-left: 15%;
  width: 70%;
}

.div-bg {
  width: 100%;
  background: #F0F0F0;
  height: 10px;
}

.box-card {
  width: 100%;
  margin-top: 20px;
  padding: 20px;
}

.el-col {
  padding-left: 5px;
}

.divider-title {
  font-weight: bold;
  font-size: 18px;
}

.custom-select .el-select-dropdown {
  max-height: 600px; /* 设置为你想要的高度 */
  overflow: auto; /* 添加滚动条 */
}

table {
  border-collapse: collapse; /* 确保表格的边框合并为单一边框 */
  width: 100%; /* 表格宽度 */
}

td {
  border: 1px solid #ababab; /* 设置单线边框 */
  padding: 6px; /* 单元格内边距 */
}

.el-form-item {
  margin-bottom: 0px;
}
</style>
